﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ProductManagement.Domain;
using ProductManagement.Domain.Shared;

namespace ProductManagement.EntityFrameworkCore
{
    public class ProductMapping : IEntityTypeConfiguration<Product>
    {
        public void Configure(EntityTypeBuilder<Product> b)
        {
            b.Property(q => q.Id).IsRequired().HasComment("主键Id").HasColumnType("bigint").ValueGeneratedNever();
           
            b.Property(q => q.Status).HasComment("主商品状态").HasMaxLength(20)
                                  .HasConversion(obj => obj.Value, str => ProductStatusEnum.FromValue(str));
        }
    }
}